/**
 * NodeJS 事件环理解
 */

setTimeout(() => {
  console.info('s1')
  Promise.resolve().then(() => {
    console.info('p1')
  })
  process.nextTick(() => {
    console.info('t1')
  })
})

Promise.resolve().then(() => {
  console.info('p2')
})

console.info('start')

setTimeout(() => {
  console.info('s2')
  Promise.resolve().then(() => {
    console.info('p3')
  })
  process.nextTick(() => {
    console.info('t2')
  })
})

console.info('end')

// start => end => p2 => s1 =>  t1 => p1 => s2 => t2 => p3
